package com.dao.impl;

import com.core.model.xg.Refrigeration;
import com.dao.XgDao;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author lxf
 * @date 2018/5/3 12:03
 * To change this template use Editor | File and Code Templates.
 */
@Repository("xgDao")
public class XgDaoImpl extends EntityDaoImpl implements XgDao {

    @Override
    public List<Refrigeration> findAllRefrigeration() {
        //利用左连接避免查询多的一方时n+1的问题
        String hql = "from " + Refrigeration.class.getName() + " a left outer join fetch a.excutor order by a.date";
        Query query = currentSession().createQuery(hql);
        return query.list();
    }
}
